using System;

namespace CodePlex.CodePlexClientLibrary
{
    [Command("listprojects", "List a user's CodePlex projects.", MinArgs = 1, MaxArgs = 1, UsageSummary = "<username>",
        UsageDescription = @"This command lists the projects that the user has commit access to (i.e.,
any project on which he or she is a coordinator or developer).")]
    public class ListProjectsCommand : NonAuthenticatedCommand
    {
        readonly ICodePlexProjectInfoService projectInfoService;

        public ListProjectsCommand(ICodePlexProjectInfoService projectInfoService)
        {
            this.projectInfoService = projectInfoService;
        }

        public override void Execute()
        {
            foreach (string projectName in projectInfoService.GetProjects(Arguments[0]))
                Console.WriteLine(projectName);
        }
    }
}